#include <iostream>

class Car // 抽象产品
{
public:
    virtual void show() = 0;
};

class BWM : public Car // 具体产品
{
public:
    BWM(int a) {}
    void show()
    {
        std::cout << "一辆宝马\n";
    }
};

class Benz : public Car
{
public:
    Benz(double b) {}
    void show()
    {
        std::cout << "一辆奔驰\n";
    }
};

class Audi : public Car
{
public:
    Audi(char c) {}
    void show()
    {
        std::cout << "一辆奥迪\n";
    }
};

class Factory // 工厂类：负责生产(构造)生产的产品
{
public:
    Car *CreatBMW()
    {
        return new BWM(1);
    }
    Car *CreatBenz()
    {
        return new Benz(3.14);
    }
    Car *CreatAudi()
    {
        return new Audi('e');
    }
};
int main()
{
    // Car *c = new Benz; // 不在关心对象构建的方式
    Factory f;
    Car *c = f.CreatBMW();
    c->show();
    return 0;
}